"""CreateAddressTable Migration."""

from masoniteorm.migrations import Migration


class CreateAddressTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with create("addresses") as table:
            table.increments("id")
            table.integer('uid').unsigned().comment('用户id')
            table.foreign('uid').references('id').on('users')
            table.char('name',60).comment('联系人')
            table.integer('tel',11).comment('联系人')
            table.string('address',255).comment('地址')
            table.string('detail',255).comment('地址详细')
            table.tiny_integer('is_default').default(0).comment('是否默认')
            table.tiny_integer('is_delete').default(0).comment('是否删除')
            table.timestamps()

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("addresses")
